package common;

import bean.UserService;
import org.example.exception.BeansException;
import org.example.factory.config.BeanPostProcessor;

/**
 * @Author: luyg
 * @Date: 2024/09/08/17:40
 * @Description:
 */
public class MyBeanPostProcessor implements BeanPostProcessor {
    @Override
    public Object beanProcessorBeforeInitialization(Object bean, String beanName) throws BeansException {
        if ("userService".equals(beanName)) {
            UserService userService = (UserService) bean;
            userService.setLocation("改为：北京");
        }
        return bean;
    }

    @Override
    public Object beanProcessorAfterInitialization(Object bean, String beanName) throws BeansException {
        return bean;
    }
}
